From 6ac4acde21663c294a02484fe7aa3a855aa28a27 Mon Sep 17 00:00:00 2001 From: "vhanquez@kneesa.uk.xensource.com" Date: Fri, 17 Mar 2006 09:52:05 +0000 Subject: [PATCH] Substitute kmalloc+memset by kzalloc where possible Signed-off-by: Vincent Hanquez --- linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c | 4 +--- linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c | 3 +-- linux-2.6-xen-sparse/drivers/xen/blkfront/vbd.c | 4 +--- linux-2.6-xen-sparse/drivers/xen/blktap/xenbus.c | 3 +-- linux-2.6-xen-sparse/drivers/xen/netback/xenbus.c | 3 +-- linux-2.6-xen-sparse/drivers/xen/tpmback/xenbus.c | 4 +--- linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_dev.c | 3 +-- linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c | 3 +-- 8 files changed, 8 insertions(+), 19 deletions(-) diff --git a/linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c b/linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c index b1934d129b..82625a9715 100644 --- a/linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c +++ b/linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c @@ -116,15 +116,13 @@ static int blkback_probe(struct xenbus_device *dev, const struct xenbus_device_id *id) { int err; - struct backend_info *be = kmalloc(sizeof(struct backend_info), + struct backend_info *be = kzalloc(sizeof(struct backend_info), GFP_KERNEL); if (!be) { xenbus_dev_fatal(dev, -ENOMEM, "allocating backend structure"); return -ENOMEM; } - memset(be, 0, sizeof(*be)); - be->dev = dev; dev->data = be; diff --git a/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c b/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c index 5e0b8be459..240afd2b0e 100644 --- a/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c +++ b/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c @@ -90,13 +90,12 @@ static int blkfront_probe(struct xenbus_device *dev, return err; } - info = kmalloc(sizeof(*info), GFP_KERNEL); + info = kzalloc(sizeof(*info), GFP_KERNEL); if (!info) { xenbus_dev_fatal(dev, -ENOMEM, "allocating info structure"); return -ENOMEM; } - memset(info, 0, sizeof(*info)); info->xbdev = dev; info->vdevice = vdevice; info->connected = BLKIF_STATE_DISCONNECTED; diff --git a/linux-2.6-xen-sparse/drivers/xen/blkfront/vbd.c b/linux-2.6-xen-sparse/drivers/xen/blkfront/vbd.c index b092a569ae..99b8ab1a99 100644 --- a/linux-2.6-xen-sparse/drivers/xen/blkfront/vbd.c +++ b/linux-2.6-xen-sparse/drivers/xen/blkfront/vbd.c @@ -97,12 +97,10 @@ xlbd_alloc_major_info(int major, int minor, int index) { struct xlbd_major_info *ptr; - ptr = kmalloc(sizeof(struct xlbd_major_info), GFP_KERNEL); + ptr = kzalloc(sizeof(struct xlbd_major_info), GFP_KERNEL); if (ptr == NULL) return NULL; - memset(ptr, 0, sizeof(struct xlbd_major_info)); - ptr->major = major; switch (index) { diff --git a/linux-2.6-xen-sparse/drivers/xen/blktap/xenbus.c b/linux-2.6-xen-sparse/drivers/xen/blktap/xenbus.c index 3dc91674a7..d97660d701 100644 --- a/linux-2.6-xen-sparse/drivers/xen/blktap/xenbus.c +++ b/linux-2.6-xen-sparse/drivers/xen/blktap/xenbus.c @@ -141,12 +141,11 @@ static int blkback_probe(struct xenbus_device *dev, char *frontend; int err; - be = kmalloc(sizeof(*be), GFP_KERNEL); + be = kzalloc(sizeof(*be), GFP_KERNEL); if (!be) { xenbus_dev_error(dev, -ENOMEM, "allocating backend structure"); return -ENOMEM; } - memset(be, 0, sizeof(*be)); frontend = NULL; err = xenbus_gather(dev->nodename, diff --git a/linux-2.6-xen-sparse/drivers/xen/netback/xenbus.c b/linux-2.6-xen-sparse/drivers/xen/netback/xenbus.c index 64bebdb820..526e02ab0a 100644 --- a/linux-2.6-xen-sparse/drivers/xen/netback/xenbus.c +++ b/linux-2.6-xen-sparse/drivers/xen/netback/xenbus.c @@ -76,14 +76,13 @@ static int netback_probe(struct xenbus_device *dev, const struct xenbus_device_id *id) { int err; - struct backend_info *be = kmalloc(sizeof(struct backend_info), + struct backend_info *be = kzalloc(sizeof(struct backend_info), GFP_KERNEL); if (!be) { xenbus_dev_fatal(dev, -ENOMEM, "allocating backend structure"); return -ENOMEM; } - memset(be, 0, sizeof(*be)); be->dev = dev; dev->data = be; diff --git a/linux-2.6-xen-sparse/drivers/xen/tpmback/xenbus.c b/linux-2.6-xen-sparse/drivers/xen/tpmback/xenbus.c index 9a2be8d593..6ce5f07891 100644 --- a/linux-2.6-xen-sparse/drivers/xen/tpmback/xenbus.c +++ b/linux-2.6-xen-sparse/drivers/xen/tpmback/xenbus.c @@ -67,7 +67,7 @@ static int tpmback_probe(struct xenbus_device *dev, const struct xenbus_device_id *id) { int err; - struct backend_info *be = kmalloc(sizeof(struct backend_info), + struct backend_info *be = kzalloc(sizeof(struct backend_info), GFP_KERNEL); if (!be) { @@ -76,8 +76,6 @@ static int tpmback_probe(struct xenbus_device *dev, return -ENOMEM; } - memset(be, 0, sizeof(*be)); - be->is_instance_set = 0; be->dev = dev; dev->data = be; diff --git a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_dev.c b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_dev.c index cdab7e82c2..9b51e4b4eb 100644 --- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_dev.c +++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_dev.c @@ -179,11 +179,10 @@ static int xenbus_dev_open(struct inode *inode, struct file *filp) nonseekable_open(inode, filp); - u = kmalloc(sizeof(*u), GFP_KERNEL); + u = kzalloc(sizeof(*u), GFP_KERNEL); if (u == NULL) return -ENOMEM; - memset(u, 0, sizeof(*u)); INIT_LIST_HEAD(&u->transactions); init_waitqueue_head(&u->read_waitq); diff --git a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c index a130cbcf72..017f36ccdd 100644 --- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c +++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c @@ -552,10 +552,9 @@ static int xenbus_probe_node(struct xen_bus_type *bus, } stringlen = strlen(nodename) + 1 + strlen(type) + 1; - xendev = kmalloc(sizeof(*xendev) + stringlen, GFP_KERNEL); + xendev = kzalloc(sizeof(*xendev) + stringlen, GFP_KERNEL); if (!xendev) return -ENOMEM; - memset(xendev, 0, sizeof(*xendev)); /* Copy the strings into the extra space. */ -- 2.30.2